package com.haulmont.asu.web.ui.work;

import com.haulmont.asu.entity.Work;
import com.haulmont.cuba.gui.data.impl.GroupDatasourceImpl;

import java.util.UUID;

/**
 * Author: Sergey42
 * Date: 14.11.13 10:46
 */
public class WorkDataSource extends GroupDatasourceImpl<Work, UUID> {

    public static interface SortListener {
        void handleSort(SortInfo[] sortInfos);
    }

    private SortListener sortListener;

    public SortListener getSortListener() {
        return sortListener;
    }

    public void setSortListener(SortListener sortListener) {
        this.sortListener = sortListener;
    }

    public void sort(SortInfo[] sortInfos) {
        super.sort(sortInfos);
        fireSortEvent(sortInfos);
    }

    private void fireSortEvent(SortInfo[] sortInfos) {
        if (sortListener != null)
            sortListener.handleSort(sortInfos);
    }
}
